<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
table{
  border-collapse:collapse;
}
td{
  text-align:right;
  padding:10px;
}
td:hover{
  background:orange;
  color:red;
}
</style>
	</head>
	<body>
		<script>
			function getMonthDayCount(year,month){
				var now = new Date();
				var y = year || now.getFullYear();
				var m = month || now.getMonth();
				var docount = 31;
				if(m==4 || m==6 || m==9 || m==11){
					docount = 30;
				}else if(m == 2){
					if(y%4==0  &&  y%100!=0 || y%400==0){
						docount = 29; 
					}else{
						docount = 28;
					}
				}
				return docount;
			}
			
			var w = 5;
			for(var t=1990;t<=2018;t++){
				document.write("<h2 style='clear:both'>"+t+"年</h2>");
			for(var k=1;k<=12;k++){
			document.write("<table border='1' style='float: left;margin: 10px;'>");
			document.write("<tr><td colspan='7'><h3>"+t+"年"+k+"月</h3></td></tr>");
			document.write("<tr><td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td></tr>");
			
			for(var i=1;i<=6;i++){
				document.write("<tr>");
				for(var j=1;j<=7;j++){
					document.write("<td>");
					var d = j+(i-1)*7-(w==0?7:w);
					if(d<1){
						if(k-1<=0){
							d += getMonthDayCount(t-1,12);
						}else{
							d += getMonthDayCount(t,k-1);
						}
					}else if(d>getMonthDayCount(t,k)){
						d -= getMonthDayCount(t,k);
					}
					document.write(d);
					document.write("</td>");
				}
				document.write("</tr>");
			}
			document.write("</table>");
			w = getMonthDayCount(t,k)%7+w%7;
			if(w>=7) w = w - 7;
		}
	}
		</script>
	</body>
</html>
